package com.medical.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.medical.mapper.ShippingMapper;
import com.medical.pojo.CleaningWorkorder;
import com.medical.pojo.Shippingapplication;
import com.medical.service.ShippingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 * @author Jerry.xu
 * @date 2024/11/25
 */

@Service
public class ShippingServiceImpl implements ShippingService {
    @Autowired
    private ShippingMapper shippingMapper;
    /**
     * 根据条件分页查询所有出货申请
     *
     * @param shippingapplication 出货申请条件，用于筛选查询结果
     * @param pageNo 当前页码，用于分页查询
     * @param pageSize 每页记录数，用于分页查询
     * @return 返回包含出货申请列表的PageInfo对象，包括总记录数、总页数等分页信息
     */
    @Override
    public PageInfo findAll(Shippingapplication shippingapplication, Integer pageNo, Integer pageSize) {
        // 开始分页，传入当前页码和每页记录数
        PageHelper.startPage(pageNo, pageSize);
        // 执行查询，获取符合条件的出货申请列表
        List<Shippingapplication> shippinglist = shippingMapper.findAll(shippingapplication);
        // 创建并初始化PageInfo对象，用于封装分页查询结果
        PageInfo<Shippingapplication> pageInfo = new PageInfo<>(shippinglist);
        // 返回封装好的PageInfo对象
        return pageInfo;
    }

    /**
     * 添加Shippingapplication记录
     *
     * 该方法负责将一个Shippingapplication对象添加到数据存储中
     * 它调用了shippingMapper的add方法来执行实际的数据添加操作
     *
     * @param shippingapplication 要添加的Shippingapplication对象，包含需要存储的信息
     */
    @Override
    public void add(Shippingapplication shippingapplication) {
        shippingMapper.add(shippingapplication);
    }

    @Override
    public List<Shippingapplication> findById(Integer id) {
        return shippingMapper.findById(id);
    }

    @Override
    public void update(Shippingapplication shippingapplication) {
        shippingMapper.update(shippingapplication);
    }

    @Override
    public List<Shippingapplication> findByCondition(Shippingapplication shippingapplication) {
        return shippingMapper.findByCondition(shippingapplication);
    }

    @Override
    public List<Shippingapplication> findByIds(Integer id) {
        return shippingMapper.findByIds(id);
    }

    @Override
    public List<Shippingapplication> listname(String name) {
        return shippingMapper.listname(name);
    }
}
